/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package model.ReportTypes;

import functions.Dogy;
import java.sql.Date;
import model.User;
import stuff.FDate;

/**
 *
 * @author JArik
 */
public class VisitReport {

    private String userName, address;
    private User user;
    private double visitPrice=0, drugPrice=0, operPrice=0, drugTaxed=0;

    private double drugTax, visitTax;
    
    private FDate date;
    private boolean payedByCard;
    private int userId;

    public double getDrugTaxed() {
        return drugTaxed;
    }
    public boolean isPayedByCard() {
        return payedByCard;
    }

    public void setPayedByCard(boolean payedByCard) {
        this.payedByCard = payedByCard;
    }
    public double getDrugTaxPrice()
    {
        return drugPrice - drugTaxed;
    }
    public void setDrugTaxed(double drugTaxed) {
        this.drugTaxed = drugTaxed;
    }
    public int getUserId() {
        return user.getId();
    }

    public void setUser(User user) {
        this.user = user;
    }

    public void setUserId(int userId) {
        this.userId = userId;
    }

    public String getAddress() {
        return user.getFullAddress();
        //if(address == null) return "Адрес не указан";
        //return Dogy.convertToLatin(address);
    }

    public void setAddress(String address) {
        this.address = address;
    }

    public FDate getDate() {
        return date;
    }

    public void setDate(Date date) {
        this.date = new FDate(date.getTime());
    }

    public double getDrugPrice() {
        return drugPrice;
    }

    public void setDrugPrice(double drugPrice) {
        this.drugPrice = drugPrice;
    }

    public double getOperPrice() {
        return operPrice;
    }

    public void setOperPrice(double operPrice) {
        this.operPrice = operPrice;
    }

    public String getUserName() {
        return Dogy.convertToLatin(user.getFullName());
    }

    public User getUser()
    {
        return user;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    public double getVisitPrice() {
        return visitPrice;
    }
    public double getVisitOverallPrice()
    {
        return visitPrice + operPrice;
    }
    public double getAverageDrugTax()
    {
        if(getDrugPrice() == 0 ) return Dogy.DRUG_TAX/100;
        return Dogy.roundTwoDecimals((this.getDrugPrice()/
                                                  this.getDrugTaxed()-1));
    }

    public double getAverageVisitTax()
    {
        if(getVisitOverallPrice() == 0 ) return Dogy.VAT_TAX/100;
        return Dogy.roundTwoDecimals((this.getVisitOverallPrice()/
                                          this.getVisitOverallTaxed() -1 ));
    }

    public double getVisitOverallTaxed()
    {
        return Dogy.roundTwoDecimals((visitPrice + operPrice)/(1+(Dogy.VAT_TAX/100)));
    }
    public double getVisitTaxPrice()
    {
        return  Dogy.roundTwoDecimals(getVisitOverallPrice() - getVisitOverallTaxed());
    }
    public void setVisitPrice(double visitPrice) {
        this.visitPrice = visitPrice;
    }

    public double getTotalIncome()
    {
        return drugTaxed + getVisitOverallTaxed();
    }
    public double getTotalPrice()
    {
        return drugPrice + getVisitOverallPrice();
    }
    public double getOverallTaxPrice()
    {
        return getVisitTaxPrice() + getDrugTaxPrice();
    }

    public String toString()
    {
        return user.getSurname();
    }
}
